:- use_module(library(lists)).
:- use_module(library(apply_macros)).

:-['1.pl'].



/* what variables required? -- end node(base case); start node (stop)
1. score related to each returned hypothesis -- it is contained in the variable of hypothesis: [ClaID-Length-EIList,] -- which Cla is specially for which example can be determined from this information.
The length is a sum of each
The potential example covered is the union of those appeared at the EI-List.
% to improve efficiency, you may want to have seperated variable, and only alter them each time (rather than compute from scratch).

2. anything to be passed between each branch? -- is it OK to use maplist?
*/

% call hypothesisSelection(startNode,FinalHypothesis)

hypothesisSelection(endNode,[0-[]]). % no clauses at all
hypothesisSelection(CurrentNode,Hypothesis):-
	expandNode(CurrentNode,ChildNodes),
	maplist(hypothesisSelection,ChildNodes,ReturnedCandidates),
	candidateSelection(ReturnedCandidates,BestCandidates),
	% how to combine the bestCandidate with Hypothesis? -- the one to be returned

% (1) only one (2) beam search -- consider those equal score
% 
	
% How to make endNode unit with others? -- in case one endNode -- need a score for it. yes including that branch. 
% all branches that are scored more than zero. -- 

	
	



expandNode(CurrentNode,ChildNodes):-
	findall(Child,connect(CurrentNode,Child),ChildNodes).




/* The previous selection method (backwards competing) looks fine , then why do u need forward selection? 

The dilemma is for one example, the best one have to consider the others, while the others although cover more, maybe trade-off for expensive description length.
This dilemma is solved by Minimum Description Length. -- a balance between coverage and description length. 

With the heuristic, which is non-overstimated, it is A*, so optimal. 
*/


candidateSelection(ReturnedCandidates,BestCandidates):-
	% combining those nonZero branches -- filter out those nonZero branches first.
	

% when to score? -- s

